<?php
use pft\Member\MemberAccount;//要放在文件的第一行位置
include_once('common/autoload.php');
//设置上传目录
$path = "upload/";	

if (!empty($_FILES)) {
	
	//得到上传的临时文件流
	$tempFile = $_FILES['Filedata']['tmp_name'];
	
	//允许的文件后缀
	$fileTypes = array('jpg','jpeg','gif','png'); 
	
	//得到文件原名
	$fileName = iconv("UTF-8","GB2312",$_FILES["Filedata"]["name"]);
	$fileParts = pathinfo($_FILES['Filedata']['name']);
	
	//接受动态传值
	$files=$_POST['typeCode'];
	
	//最后保存服务器地址
	if(!is_dir($path))  mkdir($path);
	$a = $path.$fileName;
	// write_logs("move_uploaded_file1($tempFile, $a)");
	if (move_uploaded_file($tempFile, $path.$fileName)){
		echo $a;
	}else{
		echo $a;
	}

/* 	if (in_array($fileParts['extension'],$fileTypes)) {
		copy($tempFile,$targetFile);
		echo $_FILES['Filedata']['name'];//上传成功后返回给前端的数据
		file_put_contents($_POST['id'].'.txt','上传成功了！');
	} else {
		echo '不支持的文件类型';
	} */
}
function write_logs($txt,$file="abc/uploadfy.txt"){
	$fp = fopen($file,"a");
	flock($fp, LOCK_EX);
	fwrite($fp,date("Y-m-d H:i:s").":".$txt."\n");
	flock($fp, LOCK_UN);
	fclose($fp);
}
?>